﻿// -
// <copyright file="ServiceRequest.cs" company="Microsoft Corporation">
//    Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
// -

namespace Hawaii.Services.Client
{
    using System;
    using System.Net;
    using System.IO;
    using System.Threading;

    /// <summary>
    /// State information to remember during FakeGetRequestStream calls.
    /// </summary>
    internal class ServiceRequest
    {
        /// <summary>
        /// The outstanding request.
        /// </summary>
        private HttpWebRequest request;

        /// <summary>
        /// The request stream for the request.
        /// </summary>
        private Stream stream;

        /// <summary>
        /// The event to wait on while BeginGetRequest is outstanding.
        /// </summary>
        private ManualResetEvent waiter;

        /// <summary>
        /// Initializes a new instance of the FakeGetRequestStreamState class.
        /// </summary>
        /// <param name="request">The request to remember.</param>
        public ServiceRequest(HttpWebRequest request)
        {
            this.request = request;
            this.waiter = new ManualResetEvent(false);
        }

        /// <summary>
        /// Gets the outstanding request.
        /// </summary>
        public HttpWebRequest Request
        {
            get { return this.request; }
        }

        /// <summary>
        /// Gets or sets the request stream for the request.
        /// </summary>
        public Stream Stream
        {
            get { return this.stream; }
            set { this.stream = value; }
        }

        /// <summary>
        /// Gets the event to wait on while BeginGetResponse is outstanding.
        /// </summary>
        public ManualResetEvent Waiter
        {
            get { return this.waiter; }
        }
    }
}
